import logging

class HasRequestFilter(logging.Filter):
    """
    仅允许包含 request 属性的日志通过
    这样普通的系统日志就不会写进数据库
    """
    def filter(self, record: logging.LogRecord) -> bool:
        return hasattr(record, "request")